//
//  Response.swift
//  ExRequest
//
//  Created by 王渊鸥 on 2018/8/12.
//  Copyright © 2018 WangYuanOu. All rights reserved.
//

import Foundation

public extension Dictionary where Key : StringProtocol {
    public func parse(codeKey:Key = "code", errorKey:Key = "error", dataKey:Key = "data") -> (code:Int, error:String?, data:[String:Any]?) {
        let code:Int = (self[codeKey] as? Int) ?? 0
        let error:String? = self[errorKey] as? String
        let data:[String:Any]? = self[dataKey] as? [String:Any]
        
        return (code:code, error:error, data:data)
    }
}
